﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;


namespace Site
{
    public partial class ChartView : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string Type = Page.Request.QueryString["DataType"];
            string Data = Page.Request.QueryString["Data"];
            string YAxis = Page.Request.QueryString["YAxis"];
            if (Data == null)
            {
                return;
            }

            List<string> Items = new System.Collections.Generic.List<string>();
            foreach (string s in Data.Split(','))
            {
                Items.Add(s);
            }

            FillChart(Items, YAxis);
        }

        void FillChart(List<string> Data, string YAxis)
        {
            int x = 0;
            foreach (string s in Data)
            {
                Chart1.Series.Clear();
                Chart1.Series.Add("Series" + x.ToString());
                SqlDataSource1.SelectCommand = "SELECT ["  + YAxis + "], Date FROM Data WHERE Barcode='" + s + "'";
                DataSourceSelectArguments Select = new DataSourceSelectArguments();
                DataView View = (DataView)SqlDataSource1.Select(Select);
                foreach (DataRowView row in View)
                {
                    Chart1.Series[x].Points.AddXY(row["Date"], row[YAxis]);
                }
            }
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           
        }

        protected void Chart1_Load(object sender, EventArgs e)
        {

        }

        protected void Chart1_Click(object sender, ImageMapEventArgs e)
        {

        }
    }
}